using System;
using System.Runtime.InteropServices;

public sealed class Planck
{
    public const float Emissivity = 1.0F;
    public const float ReflectedTemperature = 293.15F;
    public const float AtmosphericTemperature = 293.15F;
    public const float Distance = 1.0F;
    public const float RelativeHumidity = 0.5F;
    public const float ExternalOpticsTransmission = 1.0F;

    public static void ConvertTemperature(float emissivity, float reflectedTemperature, float atmosphericTemperature, float distance, float relativeHumidity, float[] values, int from, int to)
    {
        ConvertTemperature(
            Emissivity, emissivity,
            ReflectedTemperature, reflectedTemperature,
            AtmosphericTemperature, atmosphericTemperature,
            Distance, distance,
            RelativeHumidity, relativeHumidity,
            values, from, to);
    }

    public static void ConvertTemperature(
        float fromEmissivity, float toEmissivity,
        float fromReflectedTemperature, float toReflectedTemperature,
        float fromAtmosphericTemperature, float toAtmosphericTemperature,
        float fromDistance, float toDistance,
        float fromRelativeHumidity, float toRelativeHumidity,
        float[] values, int from, int to)
    {
        int count = values.Length;
        IntPtr hValues = IntPtr.Zero;
        try
        {
            hValues = Marshal.AllocHGlobal(count * sizeof(float));
            Marshal.Copy(values, 0, hValues, count);
            ConvertTemperature(
                fromEmissivity, toEmissivity,
                fromReflectedTemperature, toReflectedTemperature,
                fromAtmosphericTemperature, toAtmosphericTemperature,
                fromDistance, toDistance,
                fromRelativeHumidity, toRelativeHumidity,
                hValues, from, to, count);
            Marshal.Copy(hValues, values, 0, count);
        }
        finally
        {
            Marshal.FreeHGlobal(hValues);
        }
    }

    [DllImport("Planck.dll", CallingConvention = CallingConvention.Cdecl)]
    private static extern void ConvertTemperature(
        float fromEmissivity, float toEmissivity,
        float fromReflectedTemperature, float toReflectedTemperature,
        float fromAtmosphericTemperature, float toAtmosphericTemperature,
        float fromDistance, float toDistance,
        float fromRelativeHumidity, float toRelativeHumidity,
        IntPtr hValus, int from, int to, int count);
}